package com.cy7;

public class Student implements Comparable<Student> {
    private String name;
    private int chinese;
    private int math;

    public Student() {
    }

    public Student(String name, int chinese, int math) {
        this.name = name;
        this.chinese = chinese;
        this.math = math;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getChinese() {
        return chinese;
    }

    public void setChinese(int chinese) {
        this.chinese = chinese;
    }

    public int getMath() {
        return math;
    }

    public void setMath(int math) {
        this.math = math;
    }
    public int getSum(){
        return this.chinese+this.math;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", chinese=" + chinese +
                ", math=" + math +
                '}';
    }

    @Override
    public int compareTo(Student o) {
       int num1=o.getSum()-this.getSum();
       int num2=num1==0?o.getMath()-this.math:num1;
       int num3=num2==0?o.getName().compareTo(this.getName()):num2;
       return num3;
    }
}

